//
//  FKInviteInfoVC.m
//  WanTao
//
//  Created by Macbook Pro on 2019/4/18.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKInviteInfoVC.h"

@interface FKInviteInfoVC ()

@property (weak, nonatomic) IBOutlet UIImageView *avatarView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *inviteCodeLabel;
@property (weak, nonatomic) IBOutlet UILabel *levelLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

@end

@implementation FKInviteInfoVC

- (instancetype)init
{
    return [UIStoryboard storyboardWithName:@"FKInviteInfoVC" bundle:nil].instantiateInitialViewController;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self loadData];
}

#pragma mark - UITableViewDelegate
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//
//}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 0.01;
    }
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return nil;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return nil;
}

#pragma mark - 网络请求
- (void)loadData
{
    [FKHttpTool postWithSuffix:@"m=Home&c=Mine&a=inviter" param:nil success:^(FKBaseResult *result) {
        if (result.isSuccess) {
            NSDictionary *inviter = result.data[@"inviter"];
            [self.avatarView sd_setImageWithURL:[NSURL URLWithString:inviter[@"avatar"]] placeholderImage:kDefaultAvatar];
            self.nameLabel.text = inviter[@"nickname"];
            self.inviteCodeLabel.text = inviter[@"invite_code"];
            if ([inviter[@"level"] isEqualToString:@"10"]) {
                self.levelLabel.text = @"普通用户";
            } else if ([inviter[@"level"] isEqualToString:@"20"]) {
                self.levelLabel.text = @"vip会员";
            } else if ([inviter[@"level"] isEqualToString:@"30"]) {
                self.levelLabel.text = @"总监";
            } else if ([inviter[@"level"] isEqualToString:@"40"]) {
                self.levelLabel.text = @"总经理";
            }
            self.timeLabel.text = [inviter[@"in_time"] fk_timeWithFormat:@"yyyy-MM-dd"];
        }
    } failure:nil];
}

@end
